#include <stdio.h>
#include <gmp.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

int main(int argc, char **argv) {
  mpz_t sum, a;

  mpz_init(sum);
  mpz_init(a);

  mpz_set_ui(sum, 0UL);

  for (mpz_set_ui(a, 1UL); mpz_cmp_ui(a, 1000UL) < 0; mpz_add_ui(a,a,1UL)) {
    int multiple_of_3, multiple_of_5;

    multiple_of_3 = mpz_divisible_ui_p(a, 3UL);
    multiple_of_5 = mpz_divisible_ui_p(a, 5UL);

    if (multiple_of_3 != 0 || multiple_of_5 != 0)
      mpz_add(sum, sum, a);
  }

  printf("sum is: ");
  mpz_out_str(stdout, 10, sum);
  printf("\n");
}
